import {BasicColumn, FormSchema} from '@/components/Table';
import {uploadImgApi} from '@/api/sys/upload';

type CheckedType = boolean | string | number;

export const orderColumns: BasicColumn[] = [
]
export const columns: BasicColumn[] = [
  {
    title: '商品名称',//表格标题
    type: 'checkbox',
    field: 'name',
    excel_title: '*商品名称', //是否为excel导入字段 没有设置就不是
    showOverflow: 'title',
    width: 160,
  },
  {
    title: '操作事项',
    field: 'm_note',
    showOverflow: 'title',
    width: 100,
  },
  {
    title: '附加信息',
    field: 'm_remark',
    showOverflow: 'title',
    width: 120,
  },
  {
    title: '出库单号',
    field: 'orderNo',
    showOverflow: 'title',
    width: 160,
  },
  {
    title: '商品编码',
    excel_title: '商品编码', //是否为excel导入字段 没有设置就不是
    field: 'prodNumber',
    showOverflow: 'title',
    width: 120,
  },
  {
    title: '供应商',
    excel_title: '供应商', //是否为excel导入字段 没有设置就不是
    field: 'supplierName',
    showOverflow: 'title',
    width: 120,
  },

  {
    title: '计量单位',
    excel_title: '计量单位', //是否为excel导入字段 没有设置就不是
    field: 'measureUnit',
    showOverflow: 'title',

    width: 80,
  },
  {
    title: '成本价',
    excel_title: '*成本价', //是否为excel导入字段 没有设置就不是
    field: 'costPrice',
    width: 100,
  },
  {
    title: '起售价',
    excel_title: '*起售价', //是否为excel导入字段 没有设置就不是
    field: 'oriPrice',
    width: 100,
  },

  {
    title: '体积',
    excel_title: '体积', //是否为excel导入字段 没有设置就不是

    field: 'volume',
    width: 80,
  },
  {
    title: '体积单位',
    excel_title: '体积单位', //是否为excel导入字段 没有设置就不是
    field: 'volumeUnit',
    width: 80,
  },
  {
    title: '重量',
    excel_title: '重量', //是否为excel导入字段 没有设置就不是
    field: 'weight',
    width: 80,
  },
  {
    title: '重量单位',
    excel_title: '重量单位', //是否为excel导入字段 没有设置就不是
    field: 'weightUnit',
    width: 80,
  },
  {
    title: '规格组名称1',
    excel_title: '*规格组1', //是否为excel导入字段 没有设置就不是
    showOverflow: 'title',
    field: 'specGroupName1',
    width: 80,
  },
  {
    title: '规格组值1',
    excel_title: '*规格值1', //是否为excel导入字段 没有设置就不是
    showOverflow: 'title',

    field: 'specGroupValue1',
    width: 80,
  },
  {
    title: '规格组名称2',
    showOverflow: 'title',
    excel_title: '*规格组2', //是否为excel导入字段 没有设置就不是

    field: 'specGroupName2',
    width: 80,
  },
  {
    title: '规格组值2',
    showOverflow: 'title',
    excel_title: '*规格值2', //是否为excel导入字段 没有设置就不是
    field: 'specGroupValue2',
    width: 80,
  },
  {
    title: '出库数量',
    excel_title: '*录入数量', //是否为excel导入字段 没有设置就不是
    field: 'sku2Num',
    width: 80,
  },
  {
    title: 'sku成本价',
    excel_title: '*sku成本价', //是否为excel导入字段 没有设置就不是

    field: 'sku2CostPrice',
    width: 80,
  },
  {
    title: 'sku售价',
    excel_title: '*sku售价', //是否为excel导入字段 没有设置就不是
    field: 'sku2OriPrice',
    width: 80,
  },

  {
    title: 'sku商品重量',
    excel_title: 'sku商品重量', //是否为excel导入字段 没有设置就不是
    field: 'sku2Weight',
    width: 80,
  },
  {
    title: 'sku商品体积',
    excel_title: 'sku商品体积', //是否为excel导入字段 没有设置就不是
    field: 'sku2Volume',
    width: 80,
  },

  {
    title: '创建时间', //表格标题
    field: 'createTime',
    width: 180,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    span: 3,
    field: 'keyword',
    title: '查询',
    itemRender: {
      props: {
        placeholder: '产品名称',
      },
      name: 'AInput',
    },
  },

  {
    span: 3,
    field: 'orderNo',
    title: '出库单号',
    itemRender: {
      props: {
        placeholder: '出库单号',
      },
      name: 'AInput',
    },
  },
  {
    span: 3,
    field: 'specGroupValue1',
    title: '规格值1',
    itemRender: {
      props: {
        placeholder: '规格值1',
      },
      name: 'AInput',
    },
  },
  {
    span: 3,
    field: 'specGroupValue2',
    title: '规格值2',
    itemRender: {
      props: {
        placeholder: '规格值2',
      },
      name: 'AInput',
    },
  },
  {
    span: 4,
    itemRender: {
      name: 'VxeButtonGroup',
      options: [
        { type: 'reset', content: '重置' },
        { type: 'submit', content: '查询', status: 'primary' },
      ],
    },
  },
];
//: FormSchema[]
const baseFormSchema = [
  {
    field: '',
    label: '商品基本信息',
    component: 'divider',
    show:false
  },
  {
    field: '',
    label: '',
    component: 'group',
    items: [
      {
        field: 'name',
        label: '商品名称',
        required: true,
        component: 'Input',
        colProps: {
          span: 11,
        },
      },

      {
        field: 'measureUnit',
        label: '计量单位',
        required: true,
        component: 'Input',
        placeholder:"参考单位(件/包/个)",
        colProps: {
          span: 11,
        },

      },
    ],
  },
  {
    field: '',
    label: '',
    component: 'group',
    items: [
      {
        field: 'prodNumber',
        label: '编号',
        required: true,
        component: 'InputNumber',
        colProps: {
          span: 2,
          offset: 2,
        },
      },
      {
        label: '供应商',
        field: 'supplierName',
        colProps: {
          span: 2,
          offset: 2,
        },
        component: 'Input',
        // component: 'SelectSupplierIndex',
        required: true,
      },
    ],
  },

  {
    field: '',
    label: '',
    component: 'group',
    items: [
      {
        field: 'picArr',
        label: '封面图',
        required: false,
        component: 'Upload',
        componentProps: {
          api: uploadImgApi,
          multiple: true,
          accept: ['.png', '.jpeg', '.jpg'],
          resultField: 'data.data',
          maxSize: '10',
          maxNumber: '30',
          previewDelete: function (res) {
            console.log(res);
          },
          delete: function (record) {
            console.log('--delete');
            console.log(record);
          },
          change: function (list) {
            console.log('--change');
            console.log(list);
          },
        },
        colProps: {
          span: 3,
        },
      },
      {
        field: 'picsArr',
        label: '详情-主图',
        required: false,
        component: 'Upload',
        componentProps: {
          api: uploadImgApi,
          multiple: true,
          accept: ['.png', '.jpeg', '.jpg'],
          resultField: 'data.data',
          maxSize: '10',
          maxNumber: '30',
          previewDelete: function (res) {
            console.log(res);
          },
          delete: function (record) {
            console.log('--delete');
            console.log(record);
          },
          change: function (list) {
            console.log('--change');
            console.log(list);
          },
        },
        colProps: {
          span: 3,
        },
      },
      {
        field: 'details',
        label: '详情-介绍图',
        required: false,
        component: 'Upload',
        componentProps: {
          api: uploadImgApi,
          multiple: true,
          accept: ['.png', '.jpeg', '.jpg'],
          resultField: 'data.data',
          maxSize: '10',
          maxNumber: '30',
          previewDelete: function (res) {
            console.log(res);
          },
          delete: function (record) {
            console.log('--delete');
            console.log(record);
          },
          change: function (list) {
            console.log('--change');
            console.log(list);
          },
        },
        colProps: {
          span: 3,
        },

      },

    ],
  },
  {
    field: '',
    label: '',
    component: 'group',
    items: [
      {
        field: 'costPrice',
        label: '成本价',
        component: 'InputNumber',
        required: true,
        colProps: {
          span: 13,
          offset: 2,
        },
      },
      {
        field: 'oriPrice',
        label: '起售价',
        component: 'InputNumber',
        required: true,
        colProps: {
          span: 13,
          offset: 2,
        },
      },
    ],
  },

  {
    field: '',
    label: '',
    component:"group",
    items:[
      {
        field: 'weight',
        label: '重量',
        component: 'InputNumber',
        required: false,

        colProps: {
          span: 13, offset: 2
        },

      },
      {
        field: 'weightUnit',
        label: '重量单位',
        component: 'Input',
        colProps: {
          span: 13, offset: 2
        },
      },
    ]
  },
  {
    field: '',
    label: '',
    component:"group",
    items:[
      {
        field: 'volume',
        label: '体积',
        component: 'InputNumber',
        required: false,

        colProps: {
          span: 13, offset: 2
        },

      },
      {
        field: 'volumeUnit',
        label: '体积单位',
        component: 'Input',
        colProps: {
          span: 13, offset: 2
        },
      },
    ]
  },

  {
    field: 'materialNo',
    label: '物料编号',
  },


  // {
  //   label: '费用类型',
  //   field: 'costTypeId',
  //   component: 'ApiSelect',
  //   componentProps: {
  //     api: dictAllListApi,
  //     params:{type:1},
  //     resultField:"data",
  //     labelField: 'name',
  //     valueField: 'id',
  //   },
  //   required: true,
  // },
  {
    field: '',
    label: '规格信息',
    component: 'divider',
    show:false
  },
  {
    field: '',
    label: '',
    component:"group",
    items:[
      {
        field: 'skuObj',
        label: '规格',
        required: true,
        helpMessage:["限制最多两组规格"],
        component: 'productSpecForm',
        colProps: {
          span: 13, offset: 2
        },
      },

    ]
  },



];

export const formSchema = baseFormSchema;
